package com.activenetwork.util.jaxb;

import java.io.IOException;

import com.activenetwork.smlite.testcase.BaseCase;

public class ScriptDataBindHelper {
	private XMLBindHelper helper;
	
	public ScriptDataBindHelper(Class<? extends BaseCase> testCaseClass) throws IOException{
		String fullPath = testCaseClass.getName();
		String caseName = testCaseClass.getSimpleName();
		int beginIndex = fullPath.indexOf("testcase");
		int endIndex = fullPath.indexOf(caseName)-1;
		String prefix = fullPath.substring(beginIndex, endIndex);
		String resource = "xml/" + prefix + "/" +  caseName + ".xml";
		
		helper = new XMLBindHelper(resource);
	}
	
	public <T extends Object> T bind(Class<T> xmlRootNodeType){
		return helper.binding(xmlRootNodeType);
	}
}
